
#ifndef _RC4_H_
#define _RC4_H_

#include <string>
using std::string;

typedef unsigned char BYTE;
typedef unsigned char* PBYTE;
typedef unsigned int UINT;
typedef unsigned int*  PUINT;

#include "kernel/OgrePlatform.h"
#include "kernel/dll_cfg.h"


namespace FD
{
	namespace Kernel
	{
		class FD_Kernel_Export RC4  
		{
		public:
			RC4();
			~RC4();

		private:
			char* encrypt(const char* szSource, const char* szPassWord);
			char* decrypt(const char* szSource, const char* szPassWord);
			int rc4(const PBYTE data, UINT data_len, const PBYTE key, UINT key_len, PBYTE out, PUINT out_len);
			char* byte2hex(const PBYTE vByte,  UINT vLen);
			PBYTE hex2byte(const char* szHex);
			int getKey(const PBYTE pass, UINT pass_len, PBYTE out);
			void swap_byte(PBYTE a, PBYTE b);

		public:
			string Encrypt(const string& strSource, const string& strPassWord);
			string Decrypt(const string& strEncryptCode, const string& strPassWord);

		};
	}
}
#endif //_CRC4_H_H_